<?php

class RatingController extends Controller
{
	public function actionIndex()
	{
		$this->render('index');
	}

	public function actionRateIt()
	{
		if(isset($_POST['bookrate']))
		{
			$bookrate = $_POST['bookrate'];
			$book = Book::model()->findbypk($bookrate['id']);
			$value = $bookrate['value'];
			$book->ratepoint+=$value;
			$book->rateclick+=1;echo $book->point;
			$book->point=$book->point();
			if($book->save())
			echo $bookrate['value']." id: ".$bookrate['id'];
			$errors = $book->getErrors();
			foreach ($errors as $items) foreach ($items as $item) echo $item;
			Yii::app()->end();
		}
	}
	
	// Uncomment the following methods and override them if needed
	/*
	public function filters()
	{
		// return the filter configuration for this controller, e.g.:
		return array(
			'inlineFilterName',
			array(
				'class'=>'path.to.FilterClass',
				'propertyName'=>'propertyValue',
			),
		);
	}

	public function actions()
	{
		// return external action classes, e.g.:
		return array(
			'action1'=>'path.to.ActionClass',
			'action2'=>array(
				'class'=>'path.to.AnotherActionClass',
				'propertyName'=>'propertyValue',
			),
		);
	}
	*/
}